<?php
error_reporting(0);
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
$sqlReport = "SELECT distinct `district_id`,`district_name`,`block_id`,`block_name` FROM `tbl_lookup_location` where `district_id` = ".$distId." group by `block_id`";
$queryReport = mysql_query($sqlReport);
?>

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Report</title>
</head>

<body>

<table border="0" width="900" cellspacing="0" cellpadding="0">
	<tr>
		<td bgcolor="#E9E9E9" height="26">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
		<font face="Verdana" color="#224568">Block wise scheme wise type of connections and their number (as per PHED) </font></span><p align="center"><span style="font-size: 9pt; font-weight: 700">
		<font face="Verdana" color="#224568">Table 18</font></span></td>
	</tr>
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="900" cellspacing="0" cellpadding="0" height="47" bgcolor="#C5D8EB">
			<tr>
				<td width="134" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Name of Block</font></td>
				<td width="94" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt">
			  Type of Scheme</font></td>
				<td width="122" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Current Population served (2010)</font></td>
				<td width="114" align="center">
				<font style="font-size: 8.5pt" face="Verdana">Water Supplied (KLD)</font></td>
				<td width="132" align="center">
				<font face="Verdana" style="font-size: 8.5pt">Domestic connection (in numbers)</font></td>
				<td width="132" align="center">
				<font face="Verdana" style="font-size: 8.5pt">Non domestic connection (in numbers)</font></td>
				<td width="156" align="center">
				<font face="Verdana" style="font-size: 8.5pt">Average Connections/1000 persons</font></td>
			</tr>
		 <?php
			//$numVillage=0;
			//$numFormVill=0;
			while($rowReport = mysql_fetch_array($queryReport)) {
			//$Total1=getcur_population_for_scheme($rowReport['block_id'],"Piped");//+getcur_population_for_scheme($rowReport['block_id'],'P&T')+getcur_population_for_scheme($rowReport['block_id'],'TSS(P&T)')+getcur_population_for_scheme($rowReport['block_id'],'Sanitary Diggs');
			//$GrandTotal1+=$Total1;
			//$Total2=number_format(getWater_Supplied_domesticNo_for_scheme('water_supply',$rowReport['block_id'],"Piped"),2,'.','');//+getWater_Supplied_domesticNo_for_scheme('water_supply',$rowReport['block_id'],"P&T")+getWater_Supplied_domesticNo_for_scheme('water_supply',$rowReport['block_id'],"TSS(P&T)")+getWater_Supplied_domesticNo_for_scheme('water_supply',$rowReport['block_id'],"Sanitary Diggs"),2,'.','');
			//$GrandTotal2+=$Total2;
			//$Total3=getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"Piped");//+getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"P&T")+getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"TSS(P&T)")+getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"Sanitary Diggs");
			//$GrandTotal3+=$Total3;
			//$Total4=getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"Piped");//+getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"P&T")+getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"TSS(P&T)")+getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"Sanitary Diggs");
			//$GrandTotal4+=$Total4;
			
			$crrentpop=getcur_population_for_scheme($rowReport['block_id'],"Piped");
				$kld=getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"Piped")+getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"Piped");
				if($crrentpop==0)
				{
				$result="0.00";
				}else{
				$result=number_format(($kld/$crrentpop)*1000,2,'.','');
				}
				
				
			/*$crrentpop=getcur_population_for_scheme($rowReport['block_id'],'P&T')+getcur_population_for_scheme($rowReport['block_id'],'TSS(P&T)');
				$kld=getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"P&T")+getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"TSS(P&T)")+getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"P&T")+getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"TSS(P&T)");
				if($crrentpop==0)
				{
				$result1="0.00";
				}else{
				$result1=number_format(($kld/$crrentpop)*1000,2,'.','');
				}
				
			$crrentpop=getcur_population_for_scheme($rowReport['block_id'],'Sanitary Diggs');
				$kld=getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],'Sanitary Diggs')+getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],'Sanitary Diggs');
				
				if($crrentpop==0)
				{
				$result2="0.00";
				}else{
				$result2=number_format(($kld/$crrentpop)*1000,2,'.','');
				}*/	
			
			//$Total5=$result+$result1+$result2;
			//$GrandTotal5+=$Total5;
			
			?>
			<tr bgcolor="#FFFFFF">
				
				<td width="134" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['block_name'];  ?></font></td>
				<td align="center" width="94"><font face="Verdana" style="font-size: 8.5pt">Piped</font></td>
				<td width="122" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $totpop=getcur_population_for_scheme($rowReport['block_id'],"Piped");?></font></td>
				<td width="114" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $totwat=number_format(getWater_Supplied_domesticNo_for_scheme('water_supply',$rowReport['block_id'],"Piped"),2,'.','');?></font></td>
				<td width="132" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $totdom=getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"Piped");?></font></td>
				<td width="132" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $totnon=getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"Piped");?></td>
				<td width="156" align="center"><font face="Verdana" style="font-size: 8.5pt">
				<?php
				
				echo $result;
				?></font>				</td>
			</tr>
			<!--<tr bgcolor="#FFFFFF">
			  <td align="center"><font face="Verdana" style="font-size: 8.5pt">P&T </font></td>
		      <td width="122" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getcur_population_for_scheme($rowReport['block_id'],'P&T')+getcur_population_for_scheme($rowReport['block_id'],'TSS(P&T)');?></font></td>
		      <td width="114" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo number_format(getWater_Supplied_domesticNo_for_scheme('water_supply',$rowReport['block_id'],"P&T")+getWater_Supplied_domesticNo_for_scheme('water_supply',$rowReport['block_id'],"TSS(P&T)"),2,'.','');?></font></td>
		      <td width="132" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"P&T")+getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],"TSS(P&T)");?></font></td>
			  <td width="132" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"P&T")+getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],"TSS(P&T)");?></font></td>
			  <td width="156" align="center"><font face="Verdana" style="font-size: 8.5pt">
			    <?php
				
				//echo $result1;
				?>
			  </font></td>
		  </tr>
			<tr bgcolor="#FFFFFF">
			  <td align="center"><font face="Verdana" style="font-size: 8.5pt">Sanitary Diggs</font></td>
		      <td width="122" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getcur_population_for_scheme($rowReport['block_id'],'Sanitary Diggs');?></font></td>
		      <td width="114" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo number_format(getWater_Supplied_domesticNo_for_scheme('water_supply',$rowReport['block_id'],'Sanitary Diggs'),2,'.','');?></font></td>
		      <td width="132" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getWater_Supplied_domesticNo_for_scheme('domestic_no',$rowReport['block_id'],'Sanitary Diggs');?></font></td>
			  <td width="132" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php //echo getWater_Supplied_domesticNo_for_scheme('nondomestic_no',$rowReport['block_id'],'Sanitary Diggs');?></font></td>
			  <td width="156" align="center">
			  <font face="Verdana" style="font-size: 8.5pt">
				<?php
				
				//echo $result2;
				
				?></font>			  </td>
		  </tr>!-->
			
			<?php
			$Total1+=$totpop;
			$Total2+=$totwat;
			$Total3+=$totdom;
			$Total4+=$totnon;
			}
			?>
			<tr bgcolor="#E9E9E9">
				<td width="134" colspan="2" align="center"><font style="font-size: 8.5pt" face="Verdana">Total</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Total1;?></font></td>
				<td align="center" width="114"><font style="font-size: 8.5pt" face="Verdana"><?php echo number_format($Total2,2,'.','');?></font></td>
				<td align="center" width="132"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Total3;?></font></td>
				<td width="132" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php echo $Total4;?></font></td>
				<td width="156" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php 
				if($Total1==0)
				{
					echo "0.00";
				}else{
					echo number_format((($Total3+$Total4)/$Total1)*1000,2,'.','');
				}
				?></font></td>
			</tr>
			
			<!--<tr bgcolor="#E9E9E9">
				<td width="134" colspan="2" align="center"><font style="font-size: 8.5pt" face="Verdana">Grand Total</font></td>
				<td align="center" width="122"><font style="font-size: 8.5pt" face="Verdana"><?php //echo $GrandTotal1;?></font></td>
				<td align="center" width="114"><font style="font-size: 8.5pt" face="Verdana"><?php //echo number_format($GrandTotal2,2,'.','');?></font></td>
				<td align="center" width="132"><font style="font-size: 8.5pt" face="Verdana"><?php //echo $GrandTotal3;?></font></td>
				<td width="132" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php //echo $GrandTotal4;?></font></td>
				<td width="156" align="center"><font style="font-size: 8.5pt" face="Verdana"><?php //echo $GrandTotal5;
				/*if($GrandTotal1==0)
				{
					echo "0.00";
				}else{
					echo number_format((($GrandTotal3+$GrandTotal4)/$GrandTotal1)*1000,2,'.','');
				}*/
				
				?></font></td>
			</tr>!-->
		</table>
		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>


</body>

</html>